//#include "pch.h"
#include "RecastApi.h"

Sample_SoloMesh* CreateSoloMesh() 
{
	Sample_SoloMesh* sample = new Sample_SoloMesh();
	InputGeom* geom = new InputGeom();
	sample->setInputGeom(geom);
	return sample;
}

void CollectSettings(Sample_SoloMesh* sample, BuildSettings settings)
{
	if (!sample)
		return;
	sample->collectSettings(settings);
}

void SetBuildSettings(Sample_SoloMesh* sample, BuildSettings settings)
{
	if (!sample)
		return;
	const BuildSettings* settings1 = &settings;
	sample->setBuildSettings(settings1);
}

bool LoadMeshFile(Sample_SoloMesh* sample, const char* path)
{
	if (!sample)
		return false;
	InputGeom* geom = sample->getInputGeom();
	rcContext* ctx = sample->getCtx();
	if (!geom || !ctx)
		return false;
	return geom->loadMeshFile(ctx, path);
}

bool LoadMeshData(Sample_SoloMesh* sample, char* meshData)
{
	if (!sample)
		return false;
	InputGeom* geom = sample->getInputGeom();
	rcContext* ctx = sample->getCtx();
	if (!geom || !ctx)
		return false;
	int length = strlen(meshData);
	return geom->loadMeshData(ctx, meshData, length);
}

bool LoadMesh(Sample_SoloMesh* sample, float* m_verts, int* m_tris, int m_vertCount, int m_triCount)
{
	if (!sample)
		return false;
	InputGeom* geom = sample->getInputGeom();
	rcContext* ctx = sample->getCtx();
	if (!geom || !ctx)
		return false;
	return geom->loadMesh(ctx, m_verts, m_tris, m_vertCount, m_triCount);
}

bool LoadNavMesh(Sample_SoloMesh* sample, const char* path)
{
	if (!sample)
		return false;
	return sample->loadNavmesh(path);
}

void SaveNavMesh(Sample_SoloMesh* sample, const char* path) 
{
	if (!sample)
		return;
	sample->saveAll(path);
}

bool Build(Sample_SoloMesh* sample)
{
	if (!sample)
		return false;
	return sample->Build();
}

void FindPathStraight(Sample_SoloMesh* sample, float* m_spos, float* m_epos, float* outPoints, int* outPointCount, int m_straightPathOptions)
{
	if (!sample)
		return;
	sample->findPathStraight(m_spos, m_epos, outPoints, outPointCount, m_straightPathOptions);
}

void FindPathFollow(Sample_SoloMesh* sample, float* m_spos, float* m_epos, float* outPoints, int* outPointCount, int m_straightPathOptions)
{
	if (!sample)
		return;
	sample->findPathFollow(m_spos, m_epos, outPoints, outPointCount, m_straightPathOptions);
}

void FreeSoloMesh(Sample_SoloMesh* sample)
{
	if (!sample)
		return;
	sample->~Sample_SoloMesh();
}

void GetDrawNavMesh(Sample_SoloMesh* sample, float* vertsArray, int* vertsCount)
{
	if (!sample)
		return;
	sample->getDrawNavMesh(vertsArray, vertsCount);
}

int GetDrawNavMeshCount(Sample_SoloMesh* sample)
{
	if (!sample)
		return -1;
	return sample->getDrawNavMeshCount();
}